<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>商品列表</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        function page(n, s) {
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").attr("action", "${ctx}/sys/product/showProductList");
            $("#searchForm").submit();
            return false;
        }
    </script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#btnImport").click(function(){
                $.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true},
                    bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
            });
        });
    </script>
</head>
<body>
<div id="importBox" class="hide">
    <form id="importForm" action="${ctx}/sys/product/importProduct" method="post" enctype="multipart/form-data"
          class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
        <input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
        <input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
        <a href="${ctx}/sys/product/import/templateProduct">下载模板</a>
    </form>
</div>
<ul class="nav nav-tabs">
    <li class="active"><a href="${ctx}/sys/product/showProductList">商品列表</a></li>
   <li><a href="${ctx}/sys/product/form?sort=10">商品添加</a></li>
</ul>
<form:form id="searchForm" modelAttribute="tbProduct" action="${ctx}/sys/product/showProductList"
           method="post" class="breadcrumb form-search">
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <label>商品名称：</label><form:input path="title" htmlEscape="false" maxlength="50" class="input-medium"/>
            <span><label>商品类别：</label>
                <select id="box" name="reserveFlag" class="input-medium">
                    <option value="">全部</option>
                    <option  value="4" ${tbProduct.reserveFlag=='4'?"selected":""}>便利生活</option>
                    <option  value="3" ${tbProduct.reserveFlag=='3'?"selected":""}>生活预定</option>
                    <option  value="2" ${tbProduct.reserveFlag=='2'?"selected":""}>海外代购</option>
                </select>
            </span>
     <span><label>商品上下架：</label>
                <select  name="isStatus" class="input-medium">
                    <option value="">全部</option>
                    <option  value="1" ${tbProduct.isStatus=='1'?"selected":""}>上架</option>
                    <option  value="0" ${tbProduct.isStatus=='0'?"selected":""}>下架</option>
                </select>
            </span>
    &nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
    <input id="btnImport" class="btn btn-primary" type="button" value="导入"/></li>
</form:form>
<sys:message content="${message}"/>
<span><font style="color: #00A6C7">${message1}</font></span>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
        <tr>
            <th>商品名称</th>
            <th>商品图片</th>
            <th>商品类别</th>
            <th>条形码</th>
            <th>属性</th>
            <th>是否维护库存</th>
            <th>是否可用物业钱包</th>
            <th>是否预售商品</th>
            <th>是否每天</th>
            <th>预定起售时间</th>
            <th>预定终售时间</th>
        <%--    <th>添加时间</th>--%>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
    <c:forEach items="${page.list}" var="tbProduct">
        <tr>
            <td> <a href="${ctx}/sys/product/form?id=${tbProduct.id}" title="${tbProduct.title}">${fn:substring(tbProduct.title, 0,4)}</a></td>
            <td>
                <a href="${tbProduct.img}" target="_blank">
                    <img width="100" height="80" src="${tbProduct.img}" >
                </a>
            </td>
            <td>
                <c:choose>
                    <c:when test="${tbProduct.reserveFlag==3}">生活预定</c:when>
                    <c:when test="${tbProduct.reserveFlag==4}">便利生活</c:when>
                    <c:when test="${tbProduct.reserveFlag==2}">海外代购</c:when>
                </c:choose>
            </td>
            <td>${tbProduct.barcode}</td>
            <td>
                <c:forEach items="${tbProduct.tbAgentProduct}" var="attr">
                    属性：${attr.attr}&nbsp;&nbsp;
                    价格：${attr.price}&nbsp;&nbsp;
                    货号：${attr.unit}&nbsp;&nbsp;
                    库存：${attr.storeNum}&nbsp;&nbsp;
                    库存预警：${attr.alertStoreNum}&nbsp;&nbsp;<br/>
                </c:forEach>
            </td>
            <td><c:if test="${tbProduct.isMaintainStoreNum==0}">否</c:if><c:if test="${tbProduct.isMaintainStoreNum==1}">是</c:if></td>
            <td><c:if test="${tbProduct.isUseMqWallet==0}">否</c:if><c:if test="${tbProduct.isUseMqWallet==1}">是</c:if></td>
            <td>
                <c:choose>
                    <c:when test="${tbProduct.reserveFlag==3}">是</c:when>
                    <c:otherwise>否</c:otherwise>
                </c:choose>
            </td>
            <c:choose>
                <c:when test="${tbProduct.gender==1&&tbProduct.reserveFlag==3}">
                    <td>是</td>
                    <td><fmt:formatDate value="${tbProduct.reserveStartTime}" pattern="HH:mm"/></td>
                    <td><fmt:formatDate value="${tbProduct.reserveEndTime}" pattern="HH:mm"/></td>
                </c:when>
                <c:when test="${tbProduct.gender==0&&tbProduct.reserveFlag==3}">
                    <td>否</td>
                    <td><fmt:formatDate value="${tbProduct.reserveStartTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                    <td><fmt:formatDate value="${tbProduct.reserveEndTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                </c:when>
                <c:otherwise>
                    <td></td>
                    <td></td>
                    <td></td>
                </c:otherwise>
            </c:choose>

      <%--      <td><fmt:formatDate value="${tbProduct.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>--%>
            <td>
                <a href="${ctx}/sys/product/form?id=${tbProduct.id}">修改</a>
                <a href="${ctx}/sys/product/delete?id=${tbProduct.id}" onclick="return confirmx('确认要删除该商品吗？', this.href)">删除</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>
